// pages/user/Ioboundorders/viewOutbound/viewOutbound.js
Page({
  data: {
    currentPage: 1, // 当前页码  
    pageSize: 10, // 每页显示的条目数  
    outVentoryData: [], // 存储当前页要展示的数据
  },

  onLoad: function() {  
    this.loadData();  
  },  

  loadData: function() {  
    const startKeyIndex = (this.data.currentPage - 1) * this.data.pageSize;  
    const endKeyIndex = startKeyIndex + this.data.pageSize;  
  
    // 获取所有outVentoryData_开头的key  
    const keys = wx.getStorageInfoSync().keys.filter(key => key.startsWith('outVentoryData_'));  
  
    // 确保key的数量在范围内  
    const validKeys = keys.slice(startKeyIndex, endKeyIndex);  
  
    // 读取数据并展示  
    const outVentoryData = validKeys.map(key => wx.getStorageSync(key));  
    this.setData({ outVentoryData });  
  },  
  
  onReachBottom: function() {  
    // 滑动到底部时加载下一页数据  
    if (this.data.currentPage < Math.ceil(this.data.outVentoryData.length / this.data.pageSize)) {  
      this.setData({  
        currentPage: this.data.currentPage + 1  
      });  
      this.loadData();  
    }  
  }
});